package com.bianmaba.controllers.datacollection;

import com.bianmaba.beans.datacollection.ExecuteLog;
import com.bianmaba.commons.bean.result.QueryResult;
import com.bianmaba.commons.data.jpa.domain.request.PageableRequest;
import com.bianmaba.controllers.base.support.CrudControllerSwaggerSupport;
import com.bianmaba.services.datacollection.IExecuteLogService;
import com.bianmaba.spring.mvc.annotation.RequestResponseBodyConfig;
import com.bianmaba.spring.mvc.config.annotation.EntityParam;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedHashMap;
import java.util.List;

@Api(description = "任务执行日志API")
@RestController
@RequestMapping(value = "datacollection/executelog")
public class ExecuteLogController extends CrudControllerSwaggerSupport<ExecuteLog, String> {
    @Autowired
    private IExecuteLogService service;

    protected IExecuteLogService getService() {
        return service;
    }

    @RequestResponseBodyConfig(excludeProperties = {"data.*\\.taskInstance"})
    @RequestMapping("page_by_task_instance_id")
    public QueryResult<List<ExecuteLog>> pageByTaskInstanceId(String taskInstanceId, @EntityParam PageableRequest pageable) {
        LinkedHashMap params = new LinkedHashMap();
        params.put("taskInstance.id", taskInstanceId);
        return super.query(params, pageable);
    }

}
